package com.pug.service.advice;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pug.mapper.advice.AdviceMapper;
import com.pug.pojo.Advice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * Author: lqm
 * create: 2022/5/15 10:11
 * Lover: lqx
 *
 * @see
 */
@Service
public class AdviceServiceImplPool implements Callable<List<Advice>> {
    @Resource
    AdviceMapper adviceMapper;
    int pageNo=1;
    int pageSize=6;
//    public AdviceServiceImplPool(int pageNo,int pageSize){
//        this.pageNo=pageNo;
//        this.pageSize=pageSize;
//    }
    @Override
    public List<Advice> call() throws Exception {
        Page<Advice> page=new Page<>(pageNo,pageSize);
        //设置分页条件
        QueryWrapper<Advice> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("status",1);
        queryWrapper.orderByAsc("sorted");
        Page<Advice> page1 = adviceMapper.selectPage(page, queryWrapper);
        List<Advice> records = page1.getRecords();
        if(records==null) return new LinkedList<>();
        return records;
    }
}
